import time


if __name__ == '__main__':
    startTime = time.time()
    fileName = r"C:\Users\92149\Desktop\TDC\0523TDC原始数据\originaldata.txt"
    count_1 = 0
    count_2 = 0
    count_3 = 0
    count_4 = 0
    with open(fileName) as originalData:
        for data in originalData:
            arr = data.split(',')
            arr = list(map(int, arr))
            if arr[1] == 1 and 0 < arr[0] / 10 < 100000:
                count_1 += 1
            elif arr[1] == 2 and 0 < arr[0] / 10 < 100000:
                count_2 += 1
            elif arr[1] == 3 and 0 < arr[0] / 10 < 100000:
                count_3 += 1
            elif arr[1] == 4:
                count_4 += 1
            else:
                pass
    endTime = time.time()
    print("count_1:", count_1)
    print("count_2:", count_2)
    print("count_3:", count_3)
    print("count_4:", count_4)
    print("耗时:", endTime - startTime, "s")


# 每遇到一个4 后面所有时间 +1 微秒 originalData.txt里的时间单位为 ps   560kHz
# 每遇到一个1 △t更新
# 一个1后面如果遇到多个2 则计算多次△t
# 得到一个△t序列 以△t作横坐标 出现次数（时间一致）为纵坐标绘图
